package leetcode.剑指offer;

public class 对称二叉树28 {
    public boolean isSymmetric(TreeNode root) {
        if(root == null)
            return true;
        if (root.left == null && root.right == null)
            return true;

        if (root.left == null || root.right == null)
            return false;

        return process(root.left, root.right);

    }

    private boolean process(TreeNode left, TreeNode right) {
        if (left == null && right == null)
            return true;
        if (left == null || right == null)
            return false;
        if (left.val != right.val)
            return false;
        return process(left.left, right.right) && process(left.right, right.left);
    }
}
